//
// Created by 86150 on 2021/11/18.
//

#ifndef UNNAMED1_DETECTER_H
#define UNNAMED1_DETECTER_H
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/dnn.hpp>

class detecter
{
	private:
		cv::dnn::Net alexnet;


	public:
		std::vector<std::string> list4kind;
		std::vector<std::string> list2put;
		detecter(): alexnet(cv::dnn::readNetFromONNX("../new.onnx"))
		{
			list4kind =
					{
						"可回收物_金属食品罐",
						"其他垃圾_PE塑料袋",
						"其他垃圾_污损塑料",
						"其他垃圾_湿纸巾",
						"其他垃圾_创可贴",
						"可回收物_吹风机",
						"其他垃圾_便利贴",
						"其他垃圾_眼镜",
						"厨余垃圾_蛋糕",
						"可回收物_双肩包",
						"可回收物_布条",
						"厨余垃圾_豆腐",
						"其他垃圾_餐盒",
						"厨余垃圾_薯片",
						"有害垃圾_玻璃灯管",
						"可回收物_烟灰缸",
						"可回收物_勺子",
						"其他垃圾_烟蒂",
						"厨余垃圾_冰糖葫芦",
						"厨余垃圾_西瓜皮",
						"可回收物_毛绒玩具",
						"可回收物_被子",
						"可回收物_砧板",
						"可回收物_快递纸袋",
						"可回收物_椅子",
						"可回收物_纸袋",
						"厨余垃圾_苹果",
						"可回收物_键盘",
						"厨余垃圾_薯条",
						"可回收物_镊子",
						"可回收物_台灯",
						"可回收物_电熨斗",
						"可回收物_桌子",
						"可回收物_玻璃壶",
						"其他垃圾_百洁布",
						"厨余垃圾_粉条",
						"可回收物_纸牌",
						"厨余垃圾_蚕豆",
						"可回收物_化妆品瓶",
						"其他垃圾_草帽",
						"厨余垃圾_香蕉皮",
						"可回收物_纸张",
						"可回收物_燃气瓶",
						"可回收物_钟表",
						"可回收物_热水瓶",
						"可回收物_木质锅铲",
						"可回收物_剪刀",
						"厨余垃圾_大骨头",
						"可回收物_电动卷发棒",
						"可回收物_保温杯",
						"厨余垃圾_面包",
						"厨余垃圾_八宝粥",
						"可回收物_鼠标",
						"厨余垃圾_鸡翅",
						"可回收物_包",
						"可回收物_木质梳子",
						"可回收物_尺子",
						"其他垃圾_毛巾",
						"厨余垃圾_草莓",
						"可回收物_奶盒",
						"可回收垃圾_帽子",
						"可回收物_卡",
						"厨余垃圾_番茄",
						"可回收物_水壶",
						"厨余垃圾_鱼骨",
						"可回收物_纸箱",
						"可回收物_路由器",
						"其他垃圾_口罩",
						"可回收物_手机",
						"有害垃圾_干电池",
						"可回收物_枕头",
						"其他垃圾_干燥剂",
						"厨余垃圾_肠",
						"可回收物_燃气灶",
						"可回收物_耳机",
						"可回收物_蛋糕盒",
						"可回收物_雨伞",
						"其他垃圾_竹筷",
						"可回收物_单肩包",
						"可回收物_订书机",
						"可回收物_遥控器",
						"厨余垃圾_胡萝卜",
						"可回收物_钉子",
						"厨余垃圾_哈密瓜",
						"可回收物_笼子",
						"有害垃圾_灯泡",
						"其他垃圾_鸡毛掸",
						"其他垃圾_厨房手套",
						"厨余垃圾_甘蔗",
						"其他垃圾_一次性杯子",
						"可回收物_插线板",
						"可回收物_塑料玩具",
						"可回收物_铁丝球",
						"有害垃圾_过期药物",
						"可回收物_充电宝",
						"可回收物_轮胎",
						"有害垃圾_胶水",
						"其他垃圾_苍蝇拍",
						"厨余垃圾_茶叶",
						"其他垃圾_打火机",
						"可回收物_泡沫盒子",
						"厨余垃圾_肉类",
						"可回收物_食用油桶",
						"可回收物_手链",
						"可回收物_洗发水瓶",
						"厨余垃圾_菜根菜叶",
						"可回收物_电风扇",
						"有害垃圾_杀虫剂",
						"可回收物_灭火器",
						"可回收物_乒乓球拍",
						"有害垃圾_纽扣电池",
						"厨余垃圾_咖啡",
						"有害垃圾_药瓶",
						"其他垃圾_验孕棒",
						"可回收物_饮料瓶",
						"可回收物_鞋子",
						"可回收物_塑料盒",
						"可回收物_易拉罐",
						"厨余垃圾_汉堡",
						"可回收物_酒瓶",
						"可回收物_插头电线",
						"厨余垃圾_残渣剩饭",
						"其他垃圾_破碎花盆及碟碗",
						"可回收物_塑料碗盆",
						"可回收物_计算器",
						"可回收物_体重秤",
						"可回收物_木桶",
						"可回收物_档案袋",
						"其他垃圾_笔",
						"其他垃圾_牙签",
						"可回收物_塑料衣架",
						"厨余垃圾_瓜子",
						"可回收物_调料瓶",
						"可回收物_电动剃须刀",
						"可回收物_电路板",
						"厨余垃圾_橙子",
						"可回收物_打气筒",
						"厨余垃圾_蛋挞",
						"厨余垃圾_烤鸡",
						"其他垃圾_胶带",
						"有害垃圾_温度计",
						"其他垃圾_牙刷",
						"可回收物_袜子",
						"可回收物_锅",
						"厨余垃圾_火龙果",
						"厨余垃圾_蛋",
						"其他垃圾_搓澡巾",
						"有害垃圾_蓄电池",
						"可回收物_拉杆箱",
						"其他垃圾_一次性棉签",
						"厨余垃圾_饼干",
						"其他垃圾_涂改带",
						"厨余垃圾_菠萝",
						"厨余垃圾_巴旦木",
						"可回收物_玻璃杯",
						"可回收物_电磁炉",
						"可回收物_旧衣服",
						"厨余垃圾_冰激凌"
					};
			list2put =
					{
					"Recyclable metal food cans",

					"Other garbage _peplastic bags",

					"Other garbage contaminated plastics",

					"Other garbage wet paper towels",

					"Other junk band aids",

					"Recyclable hair dryer",

					"Other garbage post it notes",

					"Other garbage glasses",

					"Kitchen waste cake",

					"Recyclable backpack",

					"Recyclable cloth strip",

					"Kitchen waste tofu",

					"Other garbage lunch boxes",

					"Kitchen waste potato chips",

					"Hazardous waste glass lamp tube",

					"Recyclable ashtray",

					"Recyclable spoon",

					"Other garbage cigarette butts",

					"Kitchen waste ice sugar gourd",

					"Kitchen waste watermelon peel",

					"Recyclable plush toys",

					"Recyclable quilt",

					"Recyclable cutting board",

					"Recyclable express paper bag",

					"Recyclable chair",

					"Recyclable paper bag",

					"Kitchen waste apples",

					"Recyclable keyboard",

					"Kitchen waste French fries",

					"Recyclable tweezers",

					"Recyclable table lamp",

					"Recyclable electric iron",

					"Recyclable table",

					"Recyclable glass pot",

					"Other garbage cleaning cloth",

					"Kitchen waste vermicelli",

					"Recyclables cards",

					"Kitchen waste broad beans",

					"Recyclable cosmetic bottles",

					"Other garbage straw hats",

					"Kitchen waste banana peel",

					"Recyclable paper",

					"Recyclable gas bottle",

					"Recyclable clocks",

					"Recyclable thermos",

					"Recyclable wooden spatula",

					"Recyclable scissors",

					"Kitchen waste big bones",

					"Recyclable electric curling stick",

					"Recyclable thermos cup",

					"Kitchen waste bread",

					"Kitchen waste eight treasures porridge",

					"Recyclable mouse",

					"Kitchen waste chicken wings",

					"Recyclable bag",

					"Recyclable wooden comb",

					"Recyclable ruler",

					"Other garbage towels",

					"Kitchen waste strawberries",

					"Recyclable milk box",

					"Recyclable garbage hat",

					"Recyclable card",

					"Kitchen waste tomatoes",

					"Recyclable kettle",

					"Kitchen waste fish bones",

					"Recyclable carton",

					"Recyclables router",

					"Other garbage masks",

					"Recyclable mobile phone",

					"Hazardous waste dry battery",

					"Recyclable pillow",

					"Other waste desiccants",

					"Kitchen waste intestines",

					"Recyclable gas stove",

					"Recyclable headphones",

					"Recyclable cake box",

					"Recyclable umbrella",

					"Other garbage bamboo chopsticks",

					"Recyclable shoulder bag",

					"Recyclable stapler",

					"Recyclable remote control",

					"Kitchen waste carrots",

					"Recyclable nails",

					"Kitchen waste Hami melon",

					"Recyclable cage",

					"Hazardous waste light bulbs",

					"Other garbage feather duster",

					"Other garbage kitchen gloves",

					"Kitchen waste sugarcane",

					"Other garbage disposable cups",

					"Recyclable patch panel",

					"Recyclable plastic toys",

					"Recyclable wire ball",

					"Hazardous waste expired drugs",

					"Recyclable power bank",

					"Recyclable tires",

					"Hazardous waste glue",

					"Other garbage fly swatters",

					"Kitchen waste tea",

					"Other garbage lighters",

					"Recyclable foam box",

					"Kitchen waste meat",

					"Recyclable edible oil barrel",

					"Recyclable Bracelet",

					"Recyclable shampoo bottle",

					"Kitchen waste vegetable roots and leaves",

					"Recyclable electric fan",

					"Hazardous waste pesticides",

					"Recyclable fire extinguisher",

					"Recyclable table tennis racket",

					"Hazardous waste button battery",

					"Kitchen waste coffee",

					"Hazardous waste medicine bottle",

					"Other garbage pregnancy test stick",

					"Recyclable beverage bottles",

					"Recyclable shoes",

					"Recyclable plastic box",

					"Recyclables cans",

					"Kitchen waste hamburger",

					"Recyclable wine bottle",

					"Recyclable plug wire",

					"Kitchen waste leftovers",

					"Other garbage broken flower pots and bowls",

					"Recyclable plastic bowl and basin",

					"Recyclable calculator",

					"Recyclable scale",

					"Recyclables barrels",

					"Recyclable portfolio",

					"Other garbage pens",

					"Other garbage toothpicks",

					"Recyclable plastic clothes hanger",

					"Kitchen waste melon seeds",

					"Recyclable seasoning bottle",

					"Recyclable electric razor",

					"Recyclable circuit board",

					"Kitchen waste oranges",

					"Recyclable pump",

					"Kitchen waste egg tart",

					"Kitchen waste roast chicken",

					"Other garbage tape",

					"Hazardous waste thermometer",

					"Other garbage toothbrushes",

					"Recyclable socks",

					"Recyclable pot",

					"Kitchen waste fire dragon fruit",

					"Kitchen waste eggs",

					"Other garbage bath towels",

					"Hazardous waste battery",

					"Recyclable trolley box",

					"Other garbage disposable cotton swabs",

					"Kitchen waste biscuits",

					"Other garbage correction tapes",

					"Kitchen waste pineapple",

					"Kitchen waste Badan wood",

					"Recyclable glass",

					"Recyclable induction cooker",

					"Recyclables old clothes",

					"Kitchen waste ice cream"
					};
		}
	    int detect(cv::Mat my_pic)
	    {
			cv::resize(my_pic, my_pic, cv::Size(224, 224));
			cv::Mat inputBlob = cv::dnn::blobFromImage(my_pic, 1.0, cv::Size(224, 224), {}, false, false);

			alexnet.setInput(inputBlob);
			cv::Mat outcome = alexnet.forward();
			cv::sortIdx(outcome, outcome, cv::SORT_EVERY_ROW | cv::SORT_DESCENDING);
			return outcome.at<int>(0);
	    }
	    ~detecter()
	    {
	    }
};



#endif //UNNAMED1_DETECTER_H
